package com.fortune.service.impl;

import com.fortune.dao.COrderLoginDao;
import com.fortune.entity.PhoneAndPassword;
import com.fortune.service.COrderLoginService;
import com.fortune.vo.COrderLogin.COrderLoginInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class COrderLoginServiceImpl implements COrderLoginService {
    @Autowired
    private COrderLoginDao cOrderLoginDao;

    /**
     * 验证手机号是否存在
     * @param phone
     * @return
     */
    @Override
    public PhoneAndPassword finPhoneIsExist(String phone) {
        PhoneAndPassword finPhoneIsExist = cOrderLoginDao.finPhoneIsExist(phone);
        return finPhoneIsExist;
    }

    /**
     * 查询密码
     * @param mid
     * @param did
     * @param userId
     * @param phone
     * @return
     */
    @Override
    public String findPasswordByPhone(String mid, String did, String userId, String phone) {
        String findPasswordByPhone = cOrderLoginDao.findPasswordByPhone(mid, did, userId, phone);
        return findPasswordByPhone;
    }

    /**
     * 查询登陆成功返回信息
     * @param phone
     * @return
     */
    @Override
    public COrderLoginInfo findCOrderLoginInfo(String phone) {
        COrderLoginInfo findCOrderLoginInfo = cOrderLoginDao.findCOrderLoginInfo(phone);
        return findCOrderLoginInfo;
    }

    /**
     * 重置密码
     * @param userId
     * @param phone
     * @param password
     * @return
     */
    @Override
    public int editResetPassword(String userId, String phone, String password, String mid, String did) {
        int editResetPassword = cOrderLoginDao.editResetPassword(userId, phone, password, mid, did);
        return editResetPassword;
    }

    /**
     * 修改密码
     * @param userId
     * @param phone
     * @param password
     * @return
     */
    @Override
    public int editPasswordByPhone(String mid, String did, String userId, String phone, String password) {
        int editPasswordByPhone = cOrderLoginDao.editPasswordByPhone(mid, did, userId, phone, password);
        return editPasswordByPhone;
    }

    /**
     * 客户修改名字
     * @param userId
     * @param name
     * @return
     */
    @Override
    public int editCOrderName(String mid, String did, String userId, String name) {
        int editCOrderName = cOrderLoginDao.editCOrderName(mid, did ,userId, name);
        return editCOrderName;
    }

    /**
     * 查询手机号
     * @param userId
     * @return
     */
    @Override
    public String findPhone(String mid, String did, String userId) {
        String findPhone = cOrderLoginDao.findPhone(mid, did ,userId);
        return findPhone;
    }

    /**
     * 修改手机号
     * @param phone
     * @param userId
     * @return
     */
    @Override
    public int editNewPhone(String mid, String did, String phone, String userId) {
        int editNewPhone = cOrderLoginDao.editNewPhone(mid, did, phone, userId);
        return editNewPhone;
    }
}
